package com.krt.webapp.until;


import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.krt.webapp.BuildConfig;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.tencent.smtt.sdk.QbSdk;

import org.json.JSONObject;

public class MyApplication {

    private int picno;
    private String PIC_URL;
    private JSONObject updateflag;
    private AppInfo appInfo = null;

    public MyApplication(Application application) {
        initImageLoader(application.getApplicationContext());
        QbSdk.initX5Environment(application.getApplicationContext(), null);
        appInfo = Constant.appInfo;
    }

    public AppInfo getAppInfo() {
        return appInfo;
    }

    public void setAppInfo(AppInfo appInfo) {
        this.appInfo = appInfo;
    }

    public String getPIC_URL() {
        return PIC_URL;
    }

    public void setPIC_URL(String pIC_URL) {
        PIC_URL = pIC_URL;
    }

    public int getPicno() {
        return picno;
    }

    public void setPicno(int picno) {
        this.picno = picno;
    }

    public JSONObject getUpdateflag() {
        return updateflag;
    }

    public void setUpdateflag(JSONObject updateflag) {
        this.updateflag = updateflag;
    }


    //初始化imageLoader
    private void initImageLoader(Context context) {
        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
//			config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.writeDebugLogs(); // Remove for release app

        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());
    }

}
